import React, {useEffect, useState} from 'react'
import BatchUpload from '@/components/BatchUpload'
import {
	getExclSettlement,
	postExcSettlement,
	getDataChannels,
} from '@/service/merchantCenter/clue'

function ExportExcl(props: any) {
	const {info, sunchange} = props
	const [importDriverId, setImportDriverId] = useState(false) // 导入渠道列表
	useEffect(() => {
		setImportDriverId(info)
	}, [info])
	const childCange = (value: any) => {
		if (sunchange) {
			sunchange(value)
		}
	}
	// const [fileObj, setFileObj] = useState<any>()
	const column = [
		{
			title: '费用发生月份',
			dataIndex: 'expenseMouth',
			align: 'center',
			key: 'expenseMouth',
			width: 200,
		},
		{
			title: '奖励发生时间',
			dataIndex: 'rewardOccurrenceDate',
			align: 'center',
			key: 'rewardOccurrenceDate',
			width: 100,
		},
		{
			title: '渠道ID',
			dataIndex: 'ditchId',
			align: 'center',
			key: 'ditchId',
			width: 100,
		},
		{
			title: '渠道名称',
			dataIndex: 'ditchName',
			align: 'center',
			key: 'ditchName',
			width: 100,
		},
		{
			title: '类型',
			dataIndex: 'rewardsType',
			align: 'center',
			key: 'rewardsType',
			width: 200,
		},
		{
			title: '补扣费总金额',
			dataIndex: 'replenishCost',
			align: 'center',
			key: 'replenishCost',
			width: 200,
		},
		{
			title: '补费理由',
			dataIndex: 'replenishReason',
			align: 'center',
			key: 'replenishReason',
			width: 200,
		},
		{
			title: '失败原因',
			dataIndex: 'errorMsg',
			align: 'center',
			key: 'errorMsg',
			width: 200,
			fixed: 'right',
		},
	]
	return (
		<BatchUpload
			isModalOpen={importDriverId}
			setIsModalOpen={setImportDriverId}
			importData={getExclSettlement} // 导入接口
			onTableList={getDataChannels} // 获取列表数据-失败
			getListData={getDataChannels} // 获取列表数据-成功
			columns={column}
			sourceId={43}
			templateType="渠道补扣费导入模板"
			type={1}
			fileNmae="files"
			uploadFileUrl={postExcSettlement} // 文件上传接口
			title="导入渠道结算列表"
			childCange={childCange}
			width={800}
	/>
  );
}

export default ExportExcl
